package fr.toto.settings.settingPanels;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.kokotchy.betaSeriesAPI.model.SubtitleLanguage;

public class PanelSelectLang extends JPanel {

	private static final long serialVersionUID = -2016491847435194285L;
	private JCheckBox subLangVF;
	private JCheckBox subLangVO;

	public PanelSelectLang(SubtitleLanguage Langue) {

		this.setMaximumSize(new Dimension(32767, 60));
		this.setSize(new Dimension(200, 60));
		this.setAlignmentY(Component.TOP_ALIGNMENT);
		this.setLayout(new GridLayout(0, 1, 0, 0));

		JLabel lblChoixDesSoustitres = new JLabel(
				"Choix des Soustitres a télécharger :");
		this.add(lblChoixDesSoustitres);

		subLangVF = new JCheckBox("VF");
		this.add(subLangVF);

		subLangVO = new JCheckBox("VO");
		this.add(subLangVO);

		if (Langue != null) {
			if (SubtitleLanguage.VF.compareTo(Langue) == 0
					|| SubtitleLanguage.VOVF.compareTo(Langue) == 0) {
				subLangVF.setSelected(true);
			}
			if (SubtitleLanguage.VO.compareTo(Langue) == 0
					|| SubtitleLanguage.VOVF.compareTo(Langue) == 0) {
				subLangVO.setSelected(true);
			}
		}
	}

	public SubtitleLanguage getSelectedLangue() {
		if (subLangVF.isSelected() && subLangVO.isSelected())
			return SubtitleLanguage.VOVF;
		if (subLangVF.isSelected())
			return SubtitleLanguage.VF;
		if (subLangVO.isSelected())
			return SubtitleLanguage.VO;
		return SubtitleLanguage.UNKNOWN;

	}

}
